@@ -24,7 +24,8 @@ app.on('ready', function() { |
||
24 | 24 |
'min-width': 500, |
25 | 25 |
'min-height': 200, |
26 | 26 |
'accept-first-mouse': true, |
27 |
- 'title-bar-style': 'hidden' |
|
27 |
+ 'title-bar-style': 'hidden', |
|
28 |
+ 'fullscreen' : true |
|
28 | 29 |
}); |
29 | 30 |
|
30 | 31 |
// and load the index.html of the app. |
@@ -1,24 +1,61 @@ |
||
1 | 1 |
<!DOCTYPE html> |
2 | 2 |
<html class="no-js"> |
3 | 3 |
<head> |
4 |
- <title>Photon</title> |
|
4 |
+ <title>Codex</title> |
|
5 | 5 |
|
6 | 6 |
<!-- Stylesheets --> |
7 | 7 |
<link rel="stylesheet" href="../css/photon.min.css"> |
8 |
+ <link rel="stylesheet" href="../css/codex.css"> |
|
8 | 9 |
|
9 | 10 |
<!-- Javascript --> |
10 | 11 |
<script src="../bower_components/angular/angular.js"></script> |
11 | 12 |
<script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script> |
13 |
+ <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script> |
|
12 | 14 |
|
13 | 15 |
<script src="scripts/codex-app.js"></script> |
14 | 16 |
<script src="scripts/app-ctrl.js"></script> |
15 |
- <script src="../js/menu.js" charset="utf-8"></script> |
|
16 |
- <script src="../js/test.js" charset="utf-8"></script> |
|
17 |
+ <script src="scripts/sidebar-ctrl.js"></script> |
|
18 |
+ <script src="scripts/note-ctrl.js"></script> |
|
19 |
+ <script src="scripts/services/file-service.js"></script> |
|
17 | 20 |
<script src="scripts/date-formatter.js" charset="utf-8"></script> |
18 | 21 |
</head> |
19 | 22 |
<body ng-app="codexApp"> |
23 |
+ <div class="window"> |
|
20 | 24 |
|
21 |
- <div ui-view></div> |
|
25 |
+ <header class="toolbar toolbar-header"> |
|
26 |
+ <h1 class="title">Codex</h1> |
|
27 |
+ </header> |
|
22 | 28 |
|
29 |
+ |
|
30 |
+ <!-- Your app's content goes inside .window-content --> |
|
31 |
+ <div class="window-content" id="holder"> |
|
32 |
+ <div class="pane-group"> |
|
33 |
+ <div class="pane pane-sm sidebar" ng-controller="SidebarCtrl"> |
|
34 |
+ <nav class="nav-group"> |
|
35 |
+ <h5 class="nav-group-title">My Notes</h5> |
|
36 |
+ <span class="nav-group-item active" ui-sref="index"> |
|
37 |
+ <span class="icon icon-archive"></span> |
|
38 |
+ All Notes |
|
39 |
+ </span> |
|
40 |
+ <span class="nav-group-item"> |
|
41 |
+ <span class="icon icon-book"></span> |
|
42 |
+ Notebooks |
|
43 |
+ </span> |
|
44 |
+ <h5 class="nav-group-title">Favorites</h5> |
|
45 |
+ <span class="nav-group-item"> |
|
46 |
+ <span class="icon icon-star"></span> |
|
47 |
+ Starred |
|
48 |
+ </span> |
|
49 |
+ </nav> |
|
50 |
+ </div> |
|
51 |
+ <div class="pane" ui-view ></div> |
|
52 |
+ </div> |
|
53 |
+ </div> |
|
54 |
+ |
|
55 |
+ <footer class="toolbar toolbar-footer"> |
|
56 |
+ <h1 class="title" ng-bind="noteCount()"></h1> |
|
57 |
+ </footer> |
|
58 |
+ |
|
59 |
+ </div> |
|
23 | 60 |
</body> |
24 | 61 |
</html> |
@@ -8,8 +8,9 @@ |
||
8 | 8 |
* Controller of the domainManagerApp |
9 | 9 |
*/ |
10 | 10 |
angular.module('codexApp.index', []) |
11 |
- .controller('AppCtrl',['$scope', '$rootScope', function ($scope, $rootScope) { |
|
11 |
+ .controller('AppCtrl', ['$scope', '$rootScope', '$state', '$location', 'FileService', function ($scope, $rootScope, $state, $location, FileService) { |
|
12 | 12 |
|
13 |
+ $scope.files = FileService.getNotes(); |
|
13 | 14 |
|
14 | 15 |
|
15 | 16 |
var remote = require('remote') |
@@ -58,72 +59,32 @@ angular.module('codexApp.index', []) |
||
58 | 59 |
return false; |
59 | 60 |
}; |
60 | 61 |
|
61 |
- var marked = require('marked'); |
|
62 |
- console.log(marked('I am using __markdown__.')); |
|
63 | 62 |
|
64 | 63 |
|
65 |
- $scope.prettySize = function(bytes) { |
|
66 |
- if (bytes <= 1024) { |
|
67 |
- return bytes + " KB" |
|
68 |
- } else { |
|
69 |
- var megabytes = parseFloat(Math.round(bytes/1024 * 100) / 100).toFixed(0); |
|
70 |
- return megabytes + " MB" |
|
71 |
- } |
|
72 |
- } |
|
73 | 64 |
|
74 |
- $scope.getFilePathExtension = function(path) { |
|
75 |
- var filename = path.split('\\').pop().split('/').pop(); |
|
76 |
- var lastIndex = filename.lastIndexOf("."); |
|
77 |
- if (lastIndex < 1) return ""; |
|
78 |
- return filename.substr(lastIndex + 1); |
|
79 |
- } |
|
80 | 65 |
|
81 |
- $scope.getFileType = function(path) { |
|
82 |
- var extension = $scope.getFilePathExtension(path); |
|
83 |
- console.log(extension) |
|
84 |
- switch (extension) { |
|
85 |
- case "pdf": |
|
86 |
- return "Document"; |
|
87 |
- case "jpg": |
|
88 |
- return "Image"; |
|
89 |
- case "png": |
|
90 |
- return "Image"; |
|
91 |
- case "md": |
|
92 |
- return "Markdown"; |
|
93 |
- default: |
|
94 |
- return "File"; |
|
95 |
- } |
|
66 |
+ $scope.openNote = function(note){ |
|
67 |
+ //console.log($location.path()); |
|
68 |
+ console.log("openning note " + note.title + " (" + note.id + ")"); |
|
69 |
+ FileService.setCurrentNote(note) |
|
70 |
+ $state.go("note"); |
|
71 |
+ //$location.path('/notes/' + 'test1') |
|
72 |
+ //console.log($location.path()); |
|
96 | 73 |
} |
97 | 74 |
|
98 |
- var _getAllFilesFromFolder = function(dir) { |
|
99 |
- var filesystem = require("fs"); |
|
100 |
- var results = []; |
|
101 |
- filesystem.readdirSync(dir).forEach(function(file) { |
|
102 |
- |
|
103 |
- file_path = dir+'/'+file; |
|
104 |
- var stat = filesystem.statSync(file_path); |
|
105 |
- if (stat && stat.isDirectory()) { |
|
106 |
- results = results.concat(_getAllFilesFromFolder(file_path)) |
|
107 |
- } else { |
|
108 |
- var file_obj = { |
|
109 |
- name: file, |
|
110 |
- path: file_path, |
|
111 |
- size: $scope.prettySize(stat["size"]), |
|
112 |
- type: $scope.getFileType(file_path), |
|
113 |
- created_at: dateFormat(stat["birthdate"], "mediumDate"), |
|
114 |
- modified_at: dateFormat(stat["mtime"], "mediumDate"), |
|
115 |
- accessed_at: dateFormat(stat["atime"], "mediumDate") |
|
116 |
- } |
|
117 |
- results.push(file_obj); |
|
118 |
- } |
|
119 |
- |
|
120 |
- console.log(file_obj); |
|
121 |
- }); |
|
122 |
- return results; |
|
123 |
- }; |
|
124 |
- |
|
125 |
- //console.log(_getAllFilesFromFolder("/Users/james/dev/codex/codex")); |
|
126 |
- $scope.files = _getAllFilesFromFolder("/Users/james/dev/codex/codex"); |
|
75 |
+ $rootScope.$on('$stateNotFound', function(event, unfoundState, fromState, fromParams){ |
|
76 |
+ console.log(unfoundState.to); // "lazy.state" |
|
77 |
+ console.log(unfoundState.toParams); // {a:1, b:2} |
|
78 |
+ console.log(unfoundState.options); // {inherit:false} + default options |
|
79 |
+ }) |
|
127 | 80 |
|
81 |
+ $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error){ |
|
82 |
+ console.log('Change state error'); // "lazy.state" |
|
83 |
+ console.log(error) |
|
84 |
+ console.log(toState) |
|
85 |
+ console.log(toParams) |
|
86 |
+ console.log(fromState) |
|
87 |
+ console.log(fromParams) |
|
88 |
+ }) |
|
128 | 89 |
|
129 | 90 |
}]); |
@@ -10,7 +10,10 @@ |
||
10 | 10 |
angular |
11 | 11 |
.module('codexApp', [ |
12 | 12 |
'ui.router', |
13 |
- 'codexApp.index' |
|
13 |
+ 'ngSanitize', |
|
14 |
+ 'codexApp.index', |
|
15 |
+ 'codexApp.sidebar', |
|
16 |
+ 'codexApp.note' |
|
14 | 17 |
]) |
15 | 18 |
|
16 | 19 |
.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', function($stateProvider, $urlRouterProvider, $httpProvider) { |
@@ -23,13 +26,25 @@ angular |
||
23 | 26 |
|
24 | 27 |
// UI router |
25 | 28 |
// For any unmatched url, redirect to /state1 |
26 |
- $urlRouterProvider.otherwise("/"); |
|
29 |
+ |
|
27 | 30 |
$stateProvider |
28 | 31 |
.state('index', { |
29 | 32 |
url: "/", |
30 | 33 |
templateUrl: 'views/index.html', |
31 | 34 |
controller: 'AppCtrl' |
32 | 35 |
}) |
36 |
+ .state('note', { |
|
37 |
+ url: "/notes", |
|
38 |
+ templateUrl: "views/note.html", |
|
39 |
+ controller: 'NoteCtrl', |
|
40 |
+ resolve: { |
|
41 |
+ pageData: function($stateParams) { |
|
42 |
+ console.log('resolve ok') |
|
43 |
+ return 'resolve ok'; |
|
44 |
+ }, |
|
45 |
+ } |
|
46 |
+ }) |
|
47 |
+ $urlRouterProvider.otherwise("/"); |
|
33 | 48 |
|
34 | 49 |
|
35 | 50 |
}]); |
@@ -0,0 +1,35 @@ |
||
1 |
+ |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * @ngdoc function |
|
5 |
+ * @name domainManagerApp.controller:AboutCtrl |
|
6 |
+ * @description |
|
7 |
+ * # AboutCtrl |
|
8 |
+ * Controller of the domainManagerApp |
|
9 |
+ */ |
|
10 |
+angular.module('codexApp.note', []) |
|
11 |
+ .controller('NoteCtrl',['$scope', '$rootScope', '$state', 'FileService', function ($scope, $rootScope, $state, FileService) { |
|
12 |
+ |
|
13 |
+ var marked = require('marked'); |
|
14 |
+ var filesystem = require("fs"); |
|
15 |
+ |
|
16 |
+ console.log('Note opened!') |
|
17 |
+ |
|
18 |
+ $scope.note = FileService.getCurrentNote(); |
|
19 |
+ $scope.container = "note-container"; |
|
20 |
+ |
|
21 |
+ |
|
22 |
+ |
|
23 |
+ filesystem.readFile($scope.note.path, function(err, data) { |
|
24 |
+ var str = String.fromCharCode.apply(null, data); |
|
25 |
+ if(!$scope.$$phase) { |
|
26 |
+ $scope.$apply(function(){ |
|
27 |
+ $scope.note.data = marked(str); |
|
28 |
+ }); |
|
29 |
+ } else { |
|
30 |
+ $scope.note.data = marked(str); |
|
31 |
+ } |
|
32 |
+ //console.log($scope.note); |
|
33 |
+ }); |
|
34 |
+ |
|
35 |
+ }]); |
@@ -0,0 +1,177 @@ |
||
1 |
+angular.module('codexApp') |
|
2 |
+.service('FileService', [ '$rootScope', '$http', function($rootScope, $http) { |
|
3 |
+ |
|
4 |
+ var notes_dir = "/Users/james/dev/codex/codex"; |
|
5 |
+ var notes = []; |
|
6 |
+ var current_note = ""; |
|
7 |
+ |
|
8 |
+ var prettySize = function(bytes) { |
|
9 |
+ if (bytes <= 1024) { |
|
10 |
+ return bytes + " KB" |
|
11 |
+ } else { |
|
12 |
+ var megabytes = parseFloat(Math.round(bytes/1024 * 100) / 100).toFixed(0); |
|
13 |
+ return megabytes + " MB" |
|
14 |
+ } |
|
15 |
+ } |
|
16 |
+ |
|
17 |
+ var getFilePathExtension = function(path) { |
|
18 |
+ var filename = path.split('\\').pop().split('/').pop(); |
|
19 |
+ var lastIndex = filename.lastIndexOf("."); |
|
20 |
+ if (lastIndex < 1) return ""; |
|
21 |
+ return filename.substr(lastIndex + 1); |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ var getFileType = function(path) { |
|
25 |
+ var extension = getFilePathExtension(path); |
|
26 |
+ switch (extension) { |
|
27 |
+ case "pdf": |
|
28 |
+ return "Document"; |
|
29 |
+ case "jpg": |
|
30 |
+ return "Image"; |
|
31 |
+ case "png": |
|
32 |
+ return "Image"; |
|
33 |
+ case "md": |
|
34 |
+ return "Markdown"; |
|
35 |
+ default: |
|
36 |
+ return "File"; |
|
37 |
+ } |
|
38 |
+ } |
|
39 |
+ |
|
40 |
+ var directorySize = function(dir) { |
|
41 |
+ var filesystem = require("fs"); |
|
42 |
+ var size = 0; |
|
43 |
+ var results = []; |
|
44 |
+ filesystem.readdirSync(dir).forEach(function(file) { |
|
45 |
+ file_path = dir+'/'+file; |
|
46 |
+ var stat = filesystem.statSync(file_path); |
|
47 |
+ if (stat && stat.isDirectory()) { |
|
48 |
+ results = results.concat(directorySize(file_path)) |
|
49 |
+ } else { |
|
50 |
+ size = size + stat["size"]; |
|
51 |
+ } |
|
52 |
+ }); |
|
53 |
+ return size; |
|
54 |
+ } |
|
55 |
+ |
|
56 |
+ var noteCount = function(){ |
|
57 |
+ var count = $scope.notes.length |
|
58 |
+ switch (count) { |
|
59 |
+ case 0: |
|
60 |
+ return '0 notes'; |
|
61 |
+ case 1: |
|
62 |
+ return '1 note'; |
|
63 |
+ default: |
|
64 |
+ return count + ' notes'; |
|
65 |
+ } |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ var SetFileInfo = function(jsonData, dir, file_path, stat) { |
|
69 |
+ //console.log(jsonData.title); |
|
70 |
+ if (typeof(jsonData)==='undefined') jsonData = {}; |
|
71 |
+ var file_obj = { |
|
72 |
+ title: jsonData.title, |
|
73 |
+ path: file_path, |
|
74 |
+ size: prettySize(directorySize(dir)), |
|
75 |
+ type: getFileType(file_path), |
|
76 |
+ author: jsonData.author, |
|
77 |
+ index: jsonData.index, |
|
78 |
+ id: jsonData.id, |
|
79 |
+ created_at: dateFormat(stat["birthdate"], "mediumDate"), |
|
80 |
+ modified_at: dateFormat(stat["mtime"], "mediumDate"), |
|
81 |
+ accessed_at: dateFormat(stat["atime"], "mediumDate") |
|
82 |
+ } |
|
83 |
+ return file_obj; |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ var getNotesFromFolders = function(dir) { |
|
87 |
+ if (typeof(dir)==='undefined') dir = notes_dir; |
|
88 |
+ var filesystem = require("fs"); |
|
89 |
+ filesystem.readdirSync(dir).forEach(function(file) { |
|
90 |
+ |
|
91 |
+ file_path = dir+'/'+file; |
|
92 |
+ var stat = filesystem.statSync(file_path); |
|
93 |
+ if (stat && stat.isDirectory()) { |
|
94 |
+ notes = notes.concat(getNotesFromFolders(file_path)) |
|
95 |
+ } else { |
|
96 |
+ if(file == "info.json"){ |
|
97 |
+ filesystem.readFile(file_path, function(err, data) { |
|
98 |
+ var jsonData = JSON.parse(data); |
|
99 |
+ var file_obj = SetFileInfo(jsonData, dir, file_path, stat) |
|
100 |
+ notes.push(file_obj); |
|
101 |
+ }); |
|
102 |
+ } |
|
103 |
+ } |
|
104 |
+ }); |
|
105 |
+ return notes; |
|
106 |
+ }; |
|
107 |
+ |
|
108 |
+ this.getNotesFromFolders = getNotesFromFolders; |
|
109 |
+ |
|
110 |
+ var getAllFilesFromFolder = function(dir) { |
|
111 |
+ if (typeof(dir)==='undefined') dir = notes_dir; |
|
112 |
+ var filesystem = require("fs"); |
|
113 |
+ var results = []; |
|
114 |
+ filesystem.readdirSync(dir).forEach(function(file) { |
|
115 |
+ |
|
116 |
+ file_path = dir+'/'+file; |
|
117 |
+ var stat = filesystem.statSync(file_path); |
|
118 |
+ if (stat && stat.isDirectory()) { |
|
119 |
+ results = results.concat(getAllFilesFromFolder(file_path)) |
|
120 |
+ } else { |
|
121 |
+ if(file != ".DS_Store" && file != "info.json") { |
|
122 |
+ var jsonData = {}; |
|
123 |
+ var file_obj = SetFileInfo(jsonData, dir, file_path, stat) |
|
124 |
+ results.push(file_obj); |
|
125 |
+ } |
|
126 |
+ } |
|
127 |
+ |
|
128 |
+ //console.log(file_obj); |
|
129 |
+ }); |
|
130 |
+ return results; |
|
131 |
+ }; |
|
132 |
+ |
|
133 |
+ var findNoteInFolder = function(note_id, dir) { |
|
134 |
+ if (typeof(dir)==='undefined') dir = notes_dir; |
|
135 |
+ var filesystem = require("fs"); |
|
136 |
+ var results = []; |
|
137 |
+ filesystem.readdirSync(dir).forEach(function(file) { |
|
138 |
+ file_path = dir+'/'+file; |
|
139 |
+ var stat = filesystem.statSync(file_path); |
|
140 |
+ if (stat && stat.isDirectory()) { |
|
141 |
+ results = results.concat(findNoteInFolder(note_id, file_path)) |
|
142 |
+ } else { |
|
143 |
+ if(file == "info.json"){ |
|
144 |
+ filesystem.readFile(file_path, function(err, data) { |
|
145 |
+ var jsonData = JSON.parse(data); |
|
146 |
+ console.log(jsonData.id) |
|
147 |
+ if(jsonData.id == note_id){ |
|
148 |
+ var file_obj = SetFileInfo(jsonData, dir, file_path, stat) |
|
149 |
+ results.push(file_obj); |
|
150 |
+ } |
|
151 |
+ }); |
|
152 |
+ } |
|
153 |
+ } |
|
154 |
+ }); |
|
155 |
+ console.log(results); |
|
156 |
+ return results[0]; |
|
157 |
+ }; |
|
158 |
+ |
|
159 |
+ |
|
160 |
+ // RESPONSE |
|
161 |
+ this.getNotes = function() { |
|
162 |
+ notes = []; |
|
163 |
+ return getAllFilesFromFolder(); |
|
164 |
+ } |
|
165 |
+ |
|
166 |
+ this.getCurrentNote = function() { |
|
167 |
+ return current_note; |
|
168 |
+ } |
|
169 |
+ |
|
170 |
+ this.setCurrentNote = function(note) { |
|
171 |
+ //console.log("searcing for: " + note_id) |
|
172 |
+ current_note = note; |
|
173 |
+ //console.log(current_note); |
|
174 |
+ console.log("Current_note: " + current_note.title) |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+}]) |
@@ -0,0 +1,15 @@ |
||
1 |
+ |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * @ngdoc function |
|
5 |
+ * @name domainManagerApp.controller:AboutCtrl |
|
6 |
+ * @description |
|
7 |
+ * # AboutCtrl |
|
8 |
+ * Controller of the domainManagerApp |
|
9 |
+ */ |
|
10 |
+angular.module('codexApp.sidebar', []) |
|
11 |
+ .controller('SidebarCtrl',['$scope', '$rootScope', '$state', function ($scope, $rootScope, $state) { |
|
12 |
+ |
|
13 |
+ console.log('Sidebar loaded') |
|
14 |
+ |
|
15 |
+ }]); |
@@ -1,75 +1,20 @@ |
||
1 |
-<!-- .toolbar-header sits at the top of your app --> |
|
2 |
- |
|
3 |
-<div class="window"> |
|
4 |
- |
|
5 |
-<header class="toolbar toolbar-header"> |
|
6 |
- <h1 class="title">Photon</h1> |
|
7 |
-</header> |
|
8 |
- |
|
9 |
- |
|
10 |
-<!-- Your app's content goes inside .window-content --> |
|
11 |
-<div class="window-content" id="holder"> |
|
12 |
- <div class="pane-group"> |
|
13 |
- <div class="pane pane-sm sidebar"> |
|
14 |
- <nav class="nav-group"> |
|
15 |
- <h5 class="nav-group-title">Favorites</h5> |
|
16 |
- <span class="nav-group-item"> |
|
17 |
- <span class="icon icon-home"></span> |
|
18 |
- connors |
|
19 |
- </span> |
|
20 |
- <span class="nav-group-item active"> |
|
21 |
- <span class="icon icon-light-up"></span> |
|
22 |
- Photon |
|
23 |
- </span> |
|
24 |
- <span class="nav-group-item"> |
|
25 |
- <span class="icon icon-download"></span> |
|
26 |
- Downloads |
|
27 |
- </span> |
|
28 |
- <span class="nav-group-item"> |
|
29 |
- <span class="icon icon-folder"></span> |
|
30 |
- Documents |
|
31 |
- </span> |
|
32 |
- <span class="nav-group-item"> |
|
33 |
- <span class="icon icon-window"></span> |
|
34 |
- Applications |
|
35 |
- </span> |
|
36 |
- <span class="nav-group-item"> |
|
37 |
- <span class="icon icon-signal"></span> |
|
38 |
- AirDrop |
|
39 |
- </span> |
|
40 |
- <span class="nav-group-item"> |
|
41 |
- <span class="icon icon-monitor"></span> |
|
42 |
- Desktop |
|
43 |
- </span> |
|
44 |
- </nav> |
|
45 |
- </div> |
|
46 |
- |
|
47 |
- <div class="pane"> |
|
48 |
- <table class="table-striped"> |
|
49 |
- <thead> |
|
50 |
- <tr> |
|
51 |
- <th>Name</th> |
|
52 |
- <th>Kind</th> |
|
53 |
- <th>Date Modified</th> |
|
54 |
- <th>Size</th> |
|
55 |
- </tr> |
|
56 |
- </thead> |
|
57 |
- <tbody> |
|
58 |
- <tr ng-repeat="file in files"> |
|
59 |
- <td>{{file.name}}</td> |
|
60 |
- <td>{{file.type}}</td> |
|
61 |
- <td>{{file.modified_at}}</td> |
|
62 |
- <td>{{file.size}}</td> |
|
63 |
- </tr> |
|
64 |
- </tbody> |
|
65 |
- </table> |
|
66 |
- </div> |
|
67 |
- </div> |
|
68 |
-</div> |
|
69 |
- |
|
70 |
- |
|
71 |
-<footer class="toolbar toolbar-footer"> |
|
72 |
- <h1 class="title">Footer</h1> |
|
73 |
-</footer> |
|
74 |
- |
|
75 |
-</div> |
|
1 |
+<table class="table-striped"> |
|
2 |
+ <thead> |
|
3 |
+ <tr> |
|
4 |
+ <th>Name</th> |
|
5 |
+ <th>Kind</th> |
|
6 |
+ <th>Date Modified</th> |
|
7 |
+ <th>Author</th> |
|
8 |
+ <th>Size</th> |
|
9 |
+ </tr> |
|
10 |
+ </thead> |
|
11 |
+ <tbody> |
|
12 |
+ <tr ng-repeat="file in files track by $index" ng-dblclick="openNote(file)" > |
|
13 |
+ <td>{{file.path}}</td> |
|
14 |
+ <td>{{file.type}}</td> |
|
15 |
+ <td>{{file.modified_at}}</td> |
|
16 |
+ <td>{{file.author}}</td> |
|
17 |
+ <td>{{file.size}}</td> |
|
18 |
+ </tr> |
|
19 |
+ </tbody> |
|
20 |
+</table> |
@@ -0,0 +1,3 @@ |
||
1 |
+<div class="note-container"> |
|
2 |
+ <div class="note" ng-bind-html="note.data"></div> |
|
3 |
+</div> |
@@ -21,6 +21,7 @@ |
||
21 | 21 |
"dependencies": { |
22 | 22 |
"angular": "~1.4.7", |
23 | 23 |
"angular-ui": "~0.4.0", |
24 |
- "angular-ui-router": "~0.2.15" |
|
24 |
+ "angular-ui-router": "~0.2.15", |
|
25 |
+ "angular-sanitize": "~1.4.7" |
|
25 | 26 |
} |
26 | 27 |
} |
@@ -1,5 +1,7 @@ |
||
1 | 1 |
{ |
2 |
- "title" : "Test #0001", |
|
2 |
+ "title" : "Test #0001", |
|
3 | 3 |
"note_type" : "markdown", |
4 |
- "author" : "James Peret" |
|
4 |
+ "id" : "000001", |
|
5 |
+ "author" : "James Peret", |
|
6 |
+ "index" : "index.md" |
|
5 | 7 |
} |
@@ -1,5 +1,7 @@ |
||
1 | 1 |
{ |
2 |
- "title" : "Test #0002", |
|
2 |
+ "title" : "Test #0002", |
|
3 | 3 |
"note_type" : "markdown", |
4 |
- "author" : "James Peret" |
|
4 |
+ "id" : "000002", |
|
5 |
+ "author" : "James Peret", |
|
6 |
+ "index" : "index.md" |
|
5 | 7 |
} |
@@ -0,0 +1,89 @@ |
||
1 |
+# Notes |
|
2 |
+ |
|
3 |
+Links, snipets and references for the Codex App. |
|
4 |
+ |
|
5 |
+## Library Links |
|
6 |
+ |
|
7 |
+* [Isotope](http://isotope.metafizzy.co/) - Filter & sort magical layouts |
|
8 |
+* [Packery](http://packery.metafizzy.co/) - The bin-packing layout library |
|
9 |
+* [Mansonary](http://masonry.desandro.com/) - Cascading grid layout library |
|
10 |
+* [Wavesurfer.js](http://wavesurfer-js.org/) - Web Audio Waveform Visualizer |
|
11 |
+ |
|
12 |
+## List folder and files |
|
13 |
+ |
|
14 |
+In my project I use this function for getting huge amount of files. It's pretty fast (put require("FS") out to make it even faster): |
|
15 |
+ |
|
16 |
+ var _getAllFilesFromFolder = function(dir) { |
|
17 |
+ |
|
18 |
+ var filesystem = require("fs"); |
|
19 |
+ var results = []; |
|
20 |
+ |
|
21 |
+ filesystem.readdirSync(dir).forEach(function(file) { |
|
22 |
+ |
|
23 |
+ file = dir+'/'+file; |
|
24 |
+ var stat = filesystem.statSync(file); |
|
25 |
+ |
|
26 |
+ if (stat && stat.isDirectory()) { |
|
27 |
+ results = results.concat(_getAllFilesFromFolder(file)) |
|
28 |
+ } else results.push(file); |
|
29 |
+ |
|
30 |
+ }); |
|
31 |
+ |
|
32 |
+ return results; |
|
33 |
+ |
|
34 |
+ }; |
|
35 |
+ |
|
36 |
+usage is clear: |
|
37 |
+ |
|
38 |
+ _getAllFilesFromFolder(__dirname + "folder"); |
|
39 |
+ |
|
40 |
+## Electron File object |
|
41 |
+ |
|
42 |
+The DOM's File interface provides abstraction around native files in order to let users work on native files directly with the HTML5 file API. Electron has added a path attribute to the File interface which exposes the file's real path on filesystem. |
|
43 |
+ |
|
44 |
+Example on getting a real path from a dragged-onto-the-app file: |
|
45 |
+ |
|
46 |
+ <div id="holder"> |
|
47 |
+ Drag your file here |
|
48 |
+ </div> |
|
49 |
+ |
|
50 |
+ <script> |
|
51 |
+ var holder = document.getElementById('holder'); |
|
52 |
+ holder.ondragover = function () { |
|
53 |
+ return false; |
|
54 |
+ }; |
|
55 |
+ holder.ondragleave = holder.ondragend = function () { |
|
56 |
+ return false; |
|
57 |
+ }; |
|
58 |
+ holder.ondrop = function (e) { |
|
59 |
+ e.preventDefault(); |
|
60 |
+ var file = e.dataTransfer.files[0]; |
|
61 |
+ console.log('File you dragged here is', file.path); |
|
62 |
+ return false; |
|
63 |
+ }; |
|
64 |
+ </script> |
|
65 |
+ |
|
66 |
+## Using Native Node Modules |
|
67 |
+ |
|
68 |
+The most straightforward way to rebuild native modules is via the electron-rebuild package, which handles the manual steps of downloading headers and building native modules: |
|
69 |
+ |
|
70 |
+ npm install --save-dev electron-rebuild |
|
71 |
+ |
|
72 |
+ # Every time you run npm install, run this |
|
73 |
+ node ./node_modules/.bin/electron-rebuild |
|
74 |
+ |
|
75 |
+## How to read a file in AngularJS? |
|
76 |
+ |
|
77 |
+ .directive("ngFileSelect",function(){ |
|
78 |
+ return { |
|
79 |
+ link: function($scope,el){ |
|
80 |
+ el.bind("change", function(e){ |
|
81 |
+ $scope.file = (e.srcElement || e.target).files[0]; |
|
82 |
+ $scope.getFile(); |
|
83 |
+ }); |
|
84 |
+ } |
|
85 |
+ } |
|
86 |
+ |
|
87 |
+Working exapmle: http://plnkr.co/edit/y5n16v?p=preview |
|
88 |
+ |
|
89 |
+Thanks to lalalalalmbda for this [link](http://odetocode.com/blogs/scott/archive/2013/07/03/building-a-filereader-service-for-angularjs-the-service.aspx). |
@@ -0,0 +1,6 @@ |
||
1 |
+# Codex Todo List |
|
2 |
+ |
|
3 |
+* [ ] Download and install [photon](http://photonkit.com/components/) |
|
4 |
+* [ ] Install AngularJS |
|
5 |
+* [ ] Install JS Markdown converter (Redcarpet?) |
|
6 |
+* [ ] Read files from disk |
@@ -0,0 +1,18 @@ |
||
1 |
+.pane { |
|
2 |
+ height: 100%; |
|
3 |
+} |
|
4 |
+ |
|
5 |
+.note-container { |
|
6 |
+ background-color: #F6F6F6; |
|
7 |
+ padding-top: 5px; |
|
8 |
+ height: 100%; |
|
9 |
+ overflow-y: overlay; |
|
10 |
+} |
|
11 |
+ |
|
12 |
+.note-container .note { |
|
13 |
+ padding: 20px; |
|
14 |
+ padding-top: 15px; |
|
15 |
+ border-radius: 10px; |
|
16 |
+ background-color: white; |
|
17 |
+ margin: 25px; |
|
18 |
+} |